<?php

/**
 *  
 * @copyright (c) 2012 University of Geneva
 * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html
 * @author Laurent Opprecht laurent@opprecht.info
 */

/**
 * Structure step to restore one emedia activity
 */
class restore_emedia_activity_structure_step extends restore_activity_structure_step
{

    protected function define_structure()
    {

        $paths = array();
        $paths[] = new restore_path_element('emedia', '/activity/emedia');
        return $this->prepare_activity_structure($paths);
    }

    protected function process_emedia($data)
    {
        global $DB;

        $data = (object) $data;
        $oldid = $data->id;
        $data->course = $this->get_courseid();

        $newitemid = $DB->insert_record('emedia', $data);
        $this->apply_activity_instance($newitemid);
    }

    protected function after_execute()
    {
        $this->add_related_files('mod_emedia', 'intro', null);
    }

}
